﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using aspZone.Commerce.DataAccess;

namespace aspZone.Commerce.Web.App.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        protected ICategoryRepository categoryRepository;

        public HomeController(ICategoryRepository categoryRepository)
        {
            this.categoryRepository = categoryRepository;
        }

        public ActionResult Index()
        {
            ViewData["Title"] = "Home Page";
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            ViewData["Title"] = "About Page";

            return View();
        }

        public ActionResult CustomerCare()
        {
            return View();
        }

        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if (filterContext.Result is ViewResult)
            {
                MasterPageViewDataHelper.AddViewDataRequiredByMasterPage(this.HttpContext.Cache, this.ViewData, this.categoryRepository);
            }
        }
    }
}
